import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LeaseAgreementVO, LeaseAgreementForm, LeaseAgreementQuery } from '@/api/apartment/leaseAgreement/types';

/**
 * 查询租约信息列表
 * @param query
 * @returns {*}
 */

export const listLeaseAgreement = (query?: LeaseAgreementQuery): AxiosPromise<LeaseAgreementVO[]> => {
  return request({
    url: '/apartment/leaseAgreement/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询租约信息详细
 * @param id
 */
export const getLeaseAgreement = (id: string | number): AxiosPromise<LeaseAgreementVO> => {
  return request({
    url: '/apartment/leaseAgreement/' + id,
    method: 'get'
  });
};

/**
 * 新增租约信息
 * @param data
 */
export const addLeaseAgreement = (data: LeaseAgreementForm) => {
  return request({
    url: '/apartment/leaseAgreement',
    method: 'post',
    data: data
  });
};

/**
 * 修改租约信息
 * @param data
 */
export const updateLeaseAgreement = (data: LeaseAgreementForm) => {
  return request({
    url: '/apartment/leaseAgreement',
    method: 'put',
    data: data
  });
};

/**
 * 删除租约信息
 * @param id
 */
export const delLeaseAgreement = (id: string | number | Array<string | number>) => {
  return request({
    url: '/apartment/leaseAgreement/' + id,
    method: 'delete'
  });
};
